'''
Created on 2010-3-3

@author: Administrator
'''
import sys
from jolly.datastructures.PrePostVisitor import PrePostVisitor

class InOrder(PrePostVisitor):
    '''
    Adapter to convert a Visitor to a PrePostVisitor for in-order traversal.
    '''


    def __init__(self, visitor):
        '''
        (InOrder, Visitor) -> None
        Constructs a in-order visitor from the given visitor.
        '''
        super(InOrder, self).__init__()
        self._visitor=visitor
    
    def inVisit(self, obj):
        '''
        (InOrder, Object) -> None
        In-visits the given object.
        '''
        self._visitor.visit(obj)
    
    def getIsDone(self):
        '''
        (InOrder) -> bool
        Returns true if the visitor is done.
        '''
        return self._visitor.isDone
    
    @staticmethod
    def main(*argv):
        "InOrder test program."
        print InOrder.main.__doc__
        return 0

if __name__ == "__main__":
    sys.exit(InOrder.main(*sys.argv))
